import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import axios from 'axios'
import * as echarts from 'echarts'

axios.defaults.baseURL = 'http://localhost:8088'
// axios.defaults.headers['Content-Type'] = 'application/json'

axios.interceptors.request.use(
  config => {
    const aitoedu = window.sessionStorage.getItem('aitoedu')
    if (aitoedu !== null && aitoedu !== '') {
      config.headers.aitoedu = aitoedu
    }
    return config
  }
)

const app = createApp(App)
app.provide('$axios', axios)
app.config.globalProperties.$echarts = echarts

app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(ElementPlus)
app.use(router).mount('#app')
